﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DatabaseCompare.Model
{

    /// <summary>
    /// 列 信息.
    /// </summary>
    public class ColumnInfo : CompareAble, ICloneable
    {

        /// <summary>
        /// 列的顺序.
        /// </summary>
        public int ColumnId { set; get; }


        /// <summary>
        /// 数据类型.
        /// </summary>
        public string DataType { set; get; }


        /// <summary>
        /// 占用字节数.
        /// </summary>
        public int MaxLength { set; get; }

        /// <summary>
        /// 长度
        /// </summary>
        public int Precision { set; get; }

        /// <summary>
        /// 小数位数
        /// </summary>
        public int Scale { set; get; }


        /// <summary>
        /// 是否允许非空.
        /// </summary>
        public bool IsNullAble { set; get; }


        /// <summary>
        /// 是否是自增ID
        /// </summary>
        public bool IsIDEntity { set; get; }


        /// <summary>
        /// 是否是主键
        /// </summary>
        public bool IsPrimaryKey { set; get; }




        /// <summary>
        /// 克隆
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return this.MemberwiseClone();
        }



        public override string ToString()
        {
            StringBuilder buff = new StringBuilder();
            buff.Append("列[");
            buff.AppendFormat("列名={0};", Name);
            buff.AppendFormat("顺序={0};", ColumnId);
            buff.AppendFormat("数据类型={0};", DataType);
            buff.AppendFormat("字节数={0};", MaxLength);
            buff.AppendFormat("长度={0};", Precision);
            buff.AppendFormat("小数位数={0};", Scale);
            buff.AppendFormat("是否允许非空={0};", IsNullAble);
            buff.AppendFormat("是否是自增ID={0};", IsIDEntity);
            buff.AppendFormat("是否是主键={0};", IsPrimaryKey);
            buff.AppendFormat("备注/说明信息.={0}", Comment);
            buff.Append("]");
            return buff.ToString();
        }

    }

}
